<script setup>
import { computed } from 'vue';
import { ElTag } from 'element-plus';

const props = defineProps({
  order: {
    type: Object,
    required: true
  }
});

const statusMap = {
  unpaid: { type: 'warning', label: '待支付' },
  pending: { type: 'info', label: '待服务' },
  inProgress: { type: 'primary', label: '进行中' },
  completed: { type: 'success', label: '已完成' },
  cancelled: { type: 'danger', label: '已取消' }
};

const serviceTypeMap = {
  grooming: { icon: 'Scissors', label: '美容' },
  medical: { icon: 'FirstAidKit', label: '医疗' },
  boarding: { icon: 'House', label: '寄养' },
  training: { icon: 'Medal', label: '训练' }
};

const statusInfo = computed(() => statusMap[props.order.status] || { type: 'info', label: '未知' });
const serviceInfo = computed(() => serviceTypeMap[props.order.serviceType] || { icon: 'More', label: '其他' });
</script>

<template>
  <div class="order-card" @click="$emit('click')">
    <div class="order-header">
      <span class="order-id">订单号：{{ order.id }}</span>
      <span class="order-date">{{ order.date }}</span>
    </div>

    <div class="order-content">
      <div class="pet-info">
        <el-avatar :src="order.pet.avatar" :size="50" />
        <span class="pet-name">{{ order.pet.name }}</span>
      </div>

      <div class="service-info">
        <el-icon>
          <component :is="serviceInfo.icon" />
        </el-icon>
        <span class="service-name">{{ order.serviceName }}</span>
      </div>

      <div class="appointment-time">
        <el-icon><Calendar /></el-icon>
        <span>{{ order.appointmentTime }}</span>
      </div>

      <div class="order-amount">
        <span class="amount">¥{{ order.amount }}</span>
        <el-tag :type="statusInfo.type" size="small">
          {{ statusInfo.label }}
        </el-tag>
      </div>
    </div>
  </div>
</template>

<style scoped>
.order-card {
  background: #ffffff;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: all 0.3s;
}

.order-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.15);
}

.order-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  color: #909399;
  font-size: 14px;
}

.order-content {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 20px;
  align-items: center;
}

.pet-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pet-name {
  font-weight: 500;
}

.service-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.service-name {
  color: #303133;
}

.appointment-time {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #606266;
}

.order-amount {
  display: flex;
  align-items: center;
  gap: 12px;
}

.amount {
  font-weight: 600;
  color: #f56c6c;
}
</style> 